import axios from 'axios'
import { request } from '@/utils/request'


//筛选 条件
export function getConfig() {
    const url = request.baseURL + '/api/filter';
    const data = {
        callback: 'callback'
    };
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data);
    });
};



/**
 * 发送短信验证码
 * @param phone  页码
 * @returns {Promise.<TResult>|*}
 */
export function SendSmsCode(phone) {
    const url = request.baseURL + '/api/Fc/Sms/Send';
    const data = {
        phone: phone,
        smscode: ''
    };
    return axios.post(url, data).then((res) => {
        return Promise.resolve(res.data);
    });
};

/**
 * 验证短信验证码
 * @param phone  页码
 * @returns {Promise.<TResult>|*}
 */
export function VerifySmsCode(phone, smscode) {
    const url = request.baseURL + '/api/Fc/Sms/Verify';
    const data = {
        phone: phone,
        smscode: smscode
    };
    return axios.post(url, data).then((res) => {
        return Promise.resolve(res.data);
    });
};

/**
 * 发送邮箱验证码
 * @param phone  页码
 * @returns {Promise.<TResult>|*}
 */
export function SendEmailCode(email) {
    const url = request.baseURL + '/api/Fc/Sms/SendEmailCode';
    const data = {
        email: email,
        smscode: ''
    };
    return axios.post(url, data).then((res) => {
        return Promise.resolve(res.data);
    });
};

/**
 * 验证邮箱验证码
 * @param phone  页码
 * @returns {Promise.<TResult>|*}
 */
export function VerifyEmailCode(email, smscode) {
    const url = request.baseURL + '/api/Fc/Sms/VerifyEmailCode';
    const data = {
        email: email,
        smscode: smscode
    };
    return axios.post(url, data).then((res) => {
        return Promise.resolve(res.data);
    });
};


//微信 config接口注入权限验证配置
export function getWxjsConfig(cururl) {
    const url = request.baseURL + '/api/fc/wx/jsConfig';
    const data = {
        url: cururl,
        callback: 'callback'
    };
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data);
    });
};


//获取微信授权 跳转地址
export function getwxAuthorizedloginUrl(cururl) {
    const url = request.baseURL + '/api/fc/wx/authorizeUrl';
    const data = {
        backurl: cururl,//本项目授权成功之后跳转写入cookie值
        callback: 'callback'
    };
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data);
    });
};